#include<iostream>
using namespace std;
class Student
{
	int ID;
	int score;
public:
	void Initial()
	{
		int a, b;
		cin >> a >> b;
		ID = a;
		score = b;
	}
	friend void sort(Student* a, int N);
	friend int max(Student* a, int N);
	void Output()
	{
		cout << ID << " " << score << endl;
	}
};
void sort(Student* a, int N)
{
	for (int i = 0; i < N - 1; i++)
		for (int j = 0; j < N - i - 1; j++)
			if (a[j].score < a[j + 1].score)
				swap(a[j], a[j + 1]);
}
int max(Student* a, int N)
{
	int i = 0;
	for (; i < N - 1; i++)
	{
		if (a[i].score != a[i + 1].score)
			break;
	}
	for (int j = 0; j < i; j++)
		for (int k = 0; k < i - j; k++)
			if (a[k].ID > a[k + 1].ID)
				swap(a[k], a[k + 1]);
	return i;
}
int main()
{
	Student a[4];
	for (int i = 0; i < 4; i++)
		a[i].Initial();
	sort(a, 4);
	int x = max(a, 4);
	for (int i = 0; i <= x; i++)
		a[i].Output();
	return 0;
}